<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <!--<meta name="viewport" content="width=device-width, initial-scale=1.0">-->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
    <style>
        body, html{font-family: PingFangSC-Regular, sans-serif;}
        body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, dl, dt, dd, ul, ol, li, pre, form, fieldset, legend, button, input, textarea, th, td { margin:0; padding:0; }
        body, button, input, select, textarea { font:12px/1.5tahoma, arial, \5b8b\4f53; }
        h1, h2, h3, h4, h5, h6{ font-size:100%; }
        address, cite, dfn, em, var { font-style:normal; }
        code, kbd, pre, samp { font-family:couriernew, courier, monospace; }
        small{ font-size:12px; }
        ul, ol { list-style:none; }
        a { text-decoration:none; }
        a:hover { text-decoration:underline; }
        sup { vertical-align:text-top; }
        sub{ vertical-align:text-bottom; }
        legend { color:#000; }
        fieldset, img { border:0; }
        button, input, select, textarea { font-size:100%; }
        table { border-collapse:collapse; border-spacing:0; }

        .line{
            width: 100%;
            height: 10px;
            background: #f3f3f3;
        }
        .bor_no{
            border: none!important;
        }
        .red_color{
            color: #FF4954!important;
        }
        .share{
            width: 100%;
            height: 100%;
            position: absolute;
            left: 0;
            top: 0;
            background: #F3F3F3;
        }
        .downheader{
            width: 100%;
            height: 60px;
            background: #fff;
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 10px;
            box-sizing: border-box;
            position: fixed;
            z-index: 99;
        }
        .logo_img{
            width: 127px;
            height: 41px;
        }
        .logo_img img{
            width: 100%;
            height: 100%;
            display: block;
        }
        .down_btn{
            width: 100px;
            height: 35px;
            border: 1px solid #ccc;
            border-radius: 4px;
            line-height: 37px;
            text-align: center;
            font-size: 14px;
            font-weight: 400;
            color: #000;
        }
        .down_bg_box{
            width: 100%;
            height: 200px;
            overflow: hidden;
        }
        .down_bg_box img{
            width: 100%;
            height: auto;
        }
        /*.share_card_box{
            width: 100%;
            padding: 0 18px;
            box-sizing: border-box;
            position: absolute;
            top: 145px;
        }
        .share_card{
            min-height: 150px;
            background: #fff;
            border-radius: 4px;
            padding: 0 18px;
            box-sizing: border-box;
        }*/
        .share_card_box{
            width: 100%;
            padding: 0 18px;
            box-sizing: border-box;
            position: absolute;
            top: 145px;
        }
        .share_card{
            min-height: 150px;
            background: #fff;
            border-radius: 4px;
            padding:  18px;
            box-sizing: border-box;
        }
        .share_card_one{
            font-size: 16px;
            color: #2A2A2A;
            font-weight: 500;
            padding-top: 14px;
            padding-bottom: 8px;
            /* line-height: 50px; */
        }
        .share_card_two{
            font-size: 14px;
            color: #2A2A2A;
            font-weight: 400;
            border-bottom: 1px solid #DFDFDF;
            padding-bottom: 13px;
        }
        .share_card_two span{
              color: #F5A623;
         }
        .share_card_three{
             font-size: 14px;
            color: #6F757C;
            font-weight: 400;
            padding-top: 12px;
            padding-bottom: 14px;
        }
        .share_data{
            width: 100%;
            /*height: 100%;*/
            background: #fff;
        }
        .share_data_child{
            text-align: center;
            margin-top: 210px;
        }
        .share_data_one{
            font-size: 40px;
            color: #2A2A2A;
            font-weight: 700;
            padding-top: 18px;
        }
        .share_data_two{
            font-size: 12px;
            color: #2A2A2A;
            font-weight: 400;
        }
        .share_data_three{
             font-size: 14px;
            color: #2A2A2A;
            font-weight: 500;
            padding-top: 13px;
            border-bottom: 1px solid #DFDFDF;
            padding-bottom: 13px;
        }
        .share_data_flex{
            display: flex;
            align-items: center;
            min-height: 70px;
        }
        .share_data_flex>div{
            width: 50%;
            text-align: center;
        }
        .share_data_flex>div:first-child{
            border-right: 1px solid #dfdfdf;
        }
        .share_data_flex_one{
            font-size: 24px;
            color: #6F757C;
            font-weight: 600;
        }
        .share_data_flex_two{
             font-size: 12px;
            color: #C3C3C3;
            font-weight: 400;
        }
        .share_data_flex_three{
             font-size: 24px;
            color: #FF4954;
            font-weight: 600;
            position: relative;
        }
        .share_data_flex_three img{
            width: 6px;
            height: 8px;
            margin-left: 5px;
            margin-bottom: 10px;
        }
        .share_data_flex_four{
             font-size: 12px;
            color: #C3C3C3;
            font-weight: 400;
        }
        .chazhuang{
            display: flex;
            justify-content: space-between;
            align-items: center;
            height: 62px;
            padding: 0 18px;
            background: #fff;
            margin: 10px 0;
        }
        .chazhuang_left{
            font-size: 14px;
            color: #6F757C;
            font-weight: 400;
        }
        .chazhuang_right{
            font-size: 14px;
            color: #2A2A2A;
            font-weight: 400;
        }
        .zhexiantu{
            padding: 18px;
            background: #fff;
            margin-bottom: 90px;
        }
        .zhexianTab{
            font-size: 12px;
            color: #C3C3C3;
            font-weight: 500;
            margin-bottom: 18px;
            /* display: flex; */
            align-items: center;
            justify-content: space-between;
            height: 30px;
        }
        .zhexianTab div{
            /* float: left; */
        }
        .today{
            width: 40%;
            border: 1px solid #f3f3f3;
            text-align: center;
            height: 30px;
            line-height: 30px;
            border-radius: 4px;
            margin-right: 20px;
            float: left;
        }
        .other{
            width: 40%;
            display: flex;
            border: 2px solid #f3f3f3;
            text-align: center;
            height: 30px;
            line-height: 30px;
            border-radius: 4px;
        }
        .week{
            width: 24%;
            border: 2px solid #f3f3f3;
            text-align: center;
            height: 30px;
            line-height: 30px;
            border-top-right-radius: 4px;
            border-bottom-right-radius: 4px;
            float: right;
            border-left: none;
        }
        .month{
            float: right;
            border-top-left-radius: 4px;
            border-bottom-left-radius: 4px;
            border-left: 2px solid #f3f3f3;
            width: 24%;
            border: 2px solid #f3f3f3;
            text-align: center;
            height: 30px;
            line-height: 30px;
            /* border-right: none; */
        }
        .actives{
            background: #f3f3f3;
            color: #2a2a2a;
        }
        .daojishi{
            margin-top: 10px;
            background: #FF4954;
            /*min-height: 30px;*/
            padding: 5px 18px;
            font-size: 12px;
            color: #fff;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .del_btn{
            width: 100%;
            background: #2A2A2A;
            font-size: 16px;
            color: #F7D558;
            font-weight: 500;
            text-align: center;
            line-height: 48px;
            height: 48px;
            /*margin-top: 25px;*/
        }
        .flexBottom{
            position: fixed;
            z-index: 99;
            bottom: 0;
            width: 100%;
            display: none;
        }
        input{
            flex: 1;
            border-bottom: 1px solid #DFDFDF!important;
            background-color:transparent; 
            border-color:transparent;
            outline: none;
            color: #2A2A2A;
        }
        .phone{
            margin-right: 18px;
        }
        .code{

        }
        .dis_flex{
            width: 100%;
            height: 31px;
            display: flex;
            justify-content: space-between;
            position: relative;
        }
        ::-webkit-input-placeholder{
            color: #B5B5B5;
            font-size: 14px;
            font-weight: 200;
         }
         .sendBtn, .send_btn_dis{
            width: 86px;
            height: 31px;
            background: #F7D558;
            font-weight: 200;
            font-size: 12px;
            line-height: 31px;
            text-align: center;
            border-radius: 4px;
            color: #2A2A2A;
         }
         .now, .nowlook{
            margin: 25px auto 0 auto;
             width: 240px;
            height: 31px;
            background: #F7D558;
            font-weight: 200;
            font-size: 12px;
            line-height: 31px;
            text-align: center;
            border-radius: 4px;
            color: #2A2A2A;
         }
         .vcode_err_msg{
            position: absolute;
            right: 0;
            top: 0;
            font-weight: 200;
            font-size: 12px;
            line-height: 31px;
            text-align: center;
            border-radius: 4px;
            color: #FF4954;
         }
         .aleadyPhone{
            text-align: center;
            font-size: 24px;
            font-weight: 500;
            color: #C3C3C3;
            margin-top: 20px;
         }
         .aleadylingqu{
            text-align: center;
             font-size: 18px;
            font-weight: 500;
            color: #000000;
            /*padding-bottom: 20px;*/
         }

    </style>
</head>
<body>
    <div class="share">
        <div class="downheader">
            <div class="logo_img">
                <img src="./image/share_logo.png" alt="">
            </div>
            <a class="download"><div class="down_btn">立即下载</div></a>
        </div>
        <div class="down_bg_box">
            <img src="./image/share_bg.png">
        </div>
        <div class="share_card_box">
            <div class="share_card">
                <div class="share_card_two"><div>Hi, 小主~囤家<span style="color: #F5A623"> </span> 送你(1)饼珍藏版的普洱茶，输入手机号领取~</div></div>
                <div class="share_card_three">
                    <div class="dis_flex"><input class="phone" type="text" placeholder="请输入你的手机号">
                        <div class="sendBtn">获取验证码</div>
                        <div class="send_btn_dis" style="display: none;">
                            
                        </div>
                    </div>
                    <div class="dis_flex" style="margin-top: 20px"><input class="code" type="text" placeholder="请输入验证码" /><div class="vcode_err_msg"></div></div>
                </div>
                <div class="now">
                    立即领取
                </div>
            </div>
            <div class="share_card aleady" style="display: none;">
                <div class="share_card_two"><div>Hi, 小主~囤家<span style="color: #F5A623"> </span> 送你(1)饼珍藏版的普洱茶，输入手机号领取~</div></div>
                <div class="share_card_three">
                    <div class="aleadyPhone"></div>
                    <div class="aleadylingqu">已领取</div>
                </div>
                <a class="download"><div class="nowlook">
                    立即查看
                </div></a>
            </div>
        </div>

        <div class="share_data">
            <!-- <div class="share_data_child">
                <div class="share_data_one">¥1,020.00</div>
                <div class="share_data_two">历史平均</div>
                <div class="share_data_three">大湾2018年春茶熟饼</div>
            </div>
            <div class="share_data_flex">
                <div>
                    <div class="share_data_flex_one">1600</div>
                    <div class="share_data_flex_two">用户持仓量</div>
                </div>
                <div>
                    <div class="share_data_flex_three">+0.2%<img src="./image/jiantouhong.png"></div>
                    <div class="share_data_flex_four">涨幅度</div>
                </div>
            </div> -->
        </div>
        <div class="chazhuang">
            <!-- <div class="chazhuang_left">所属茶庄</div>
            <div class="chazhuang_right">普秀茶庄</div> -->
        </div>
         <div class="zhexiantu">
            <div class="zhexianTab">
                <div class="today tab actives">今日</div>
                <!-- <div class="other"> -->
                <div class="week tab">本月</div>
                <div class="month tab">本周</div>
                <!-- </div> -->
            </div>
            <div>
                <div id="container" style="width: 100%;height:200px;"></div>
            </div>
        </div>
        <div class="flexBottom">
                <div class="daojishi">小主需要48小时内进入囤囤APP领取礼物，否则礼物将被退回哦~</div>
                <a  class="download"><div class="del_btn">
                    立即接收
                </div></a>
        </div>
        
    </div>
</body>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.hcharts.cn/highcharts/highcharts.js"></script>
<script>
    $(function () {
        let arr = [];
        $.getUrlParam = function (name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]); return null;
        }
        $.get_protocol = function () {
            var s = window.location.href;
            return s.split('/')[0].split(':')[0];
        }
        $.get_host = function () {
            var s = window.location.href;
            return s.split('/')[2];
        }
        var storage = window.localStorage;
        var isLingquPhone = storage.getItem("code");
        
        let midData = storage.getItem("arr");
        var href = storage.getItem("href");
        var authcode_id = "";
        var protocol = $.get_protocol();
        var host = $.get_host();
        // if(isLingquPhone) {
        //     $(".aleady").show().siblings().hide();
        //     $(".aleadyPhone").html(isLingquPhone);
        //     $(".download").attr("href", href ? href : "javascript:;");
        // }
        var arrays = midData && JSON.parse(midData) || [];
        if(midData) {
            for(let i = 0; i < arrays.length; i++){
                console.log(arrays)
                console.log(arrays[i])
                if(arrays[i]["market_order_id"] == $.getUrlParam('id')) {
                    $(".aleady").show().siblings().hide();
                    $(".aleadyPhone").html(arrays[i]["telephone"]);
                    $(".download").attr("href", href ? href : "javascript:;");
                }
            }
        }
        

        $.extend({
            "setTimeA":function(b) {
                if(parseInt(b)>1) {
                    var timeStart = parseInt(b) - 1;
                    $(".send_btn_dis").text(timeStart + "s 后重发");
                    setTimeout(function(){$.setTimeA(timeStart)}, 1000);
                }else{
                    $(".send_btn_dis").hide();
                    $(".sendBtn").show();
                }

            }
        });
        $(".sendBtn").on("click", function() {
            $(".vcode_err_msg").html("");
            var telephone = $(".phone").val();
            var pid = $.getUrlParam("pid");
            console.log(telephone)
            $.ajax({
                type: 'POST',
                url: protocol + '://'+ host+ '/user/authcode',
                dataType: 'json',
                contentType: 'application/json',
                withCredentials: true,
                data: JSON.stringify({
                    "mobile": telephone
                }),
                success: function (data) {
                    console.log(data)
                    if(data.authcode_id) {
                        authcode_id = data.authcode_id
                        $(".sendBtn").hide();
                        $(".send_btn_dis").show()
                        $.setTimeA(60);
                    }else{
                        $(".sendBtn").show();
                        $(".send_btn_dis").hide()
                        $(".vcode_err_msg").html(data.msg)
                    }
            }})
        })
        $(".now").on("click", function() {
            $(".vcode_err_msg").html("");
            var telephone = $(".phone").val();
            var sms_code = $(".code").val();
            var market_order_id = $.getUrlParam('id');
            
            $.ajax({
                type: 'POST',
                url: protocol + '://'+ host+ '/order/pickup/giftpack/' + market_order_id,
                dataType: 'json',
                contentType: 'application/json',
                withCredentials: true,
                data: JSON.stringify({
                    "mobile": telephone,
                    "authcode": sms_code,
                    "authcode_id": authcode_id,
                    "market_order_id": market_order_id
                }),
                success: function (data) {
                    console.log(data)
                    if(!data.code) {
                        $(".aleady").show().siblings().hide();
                        $(".aleadyPhone").html(telephone);
                        arrays.push({market_order_id: market_order_id, telephone: telephone});
                        storage.setItem("arr", JSON.stringify(arrays));
                        storage.setItem("code", telephone);

                    }else{
                        console.log(data)
                        $(".vcode_err_msg").html(data.msg)
                    }
                },
                error: function(error) {
                    console.log(error)
                    console.log(error.responseText)
                    console.log(JSON.parse(error.responseText).msg)

                    $(".vcode_err_msg").html( JSON.parse(error.responseText).msg)
                }
            })
        })

        var line_data = [], weekdata = [], monthdata = [];
        var current = "今日";
        var id = $.getUrlParam('id');
        $.getUrlParam = function (name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]); return null;
        }
        var render_card = function (data) {
            var part = '<div>Hi, 小主~囤家<span>'+ data.seller_user_nickname +'</span> 送你(1)饼珍藏版的普洱茶，输入手机号领取~</div>';
            return part;
        }
        // var render_card = function (data) {
        //     var part = '<div class="share_card">'+
        //                 '<div class="share_card_one">Hi, 小主~</div>'+
        //                 '<div class="share_card_two">囤家<span>'+ data.seller_user_nickname +'</span> 送你(' + data.count + ')饼珍藏版的普洱茶，快来领取吧~</div>'+
        //                 '<div class="share_card_three">' + data.as_gift_append_memo + '</div>'+
        //             '</div>';
        //     return part;
        // }
        var render_share_data = function(data) {
            var part = 
                        '<div class="share_data_child">'+
                            '<div class="share_data_one">¥'+data.avg_price+'</div>'+
                            '<div class="share_data_two">历史平均</div>'+
                            '<div class="share_data_three">'+data.name+'</div>'+
                        '</div>'+
                        '<div class="share_data_flex">'+
                            '<div>'+
                                '<div class="share_data_flex_one">'+data.keeping_count+'</div>'+
                                '<div class="share_data_flex_two">用户持仓量</div>'+
                            '</div>'+
                            '<div>'+
                                '<div class="share_data_flex_three">+'+data.up_down_percent+'<img src="./image/jiantouhong.png"></div>'+
                                '<div class="share_data_flex_four">涨幅度</div>'+
                            '</div>'+
                        '</div>';
            return part;
        }
        var render_chazhuang = function(data) {
            var part = 
            '<div class="chazhuang_left">所属茶庄</div>'+
            '<div class="chazhuang_right">'+data.store+'</div>';
            return part

        }

        $('.tab').click(function () {
            line_data = [];
            var i = $(this).index();//下标第一种写法
            $(this).addClass('actives').siblings().removeClass('actives');
            current = $(this).html();

            $.ajax({
                type: 'GET',
                url: protocol + '://'+ host+ '/order/orders/'+ id,
                contentType: 'application/json',
                withCredentials: true,
                dataType: 'json',
                async: false,
                success: function (data) {
                    $(".download").attr("href", data.app_download_link);
                    if(current == "今日") {
                        for (var i = 0; i < data.product_info.today_price_data.points.length; i++) {
                            var point = data.product_info.today_price_data.points[i];
                            line_data.push(parseFloat(point.value));
                        }
                    }else if(current == "本周") {
                        for (var i = 0; i < data.product_info.week_price_data.points.length; i++) {
                            var point = data.product_info.week_price_data.points[i];
                            line_data.push(parseFloat(point.value));
                        }
                    }else{
                        for (var i = 0; i < data.product_info.month_price_data.points.length; i++) {
                            var point = data.product_info.month_price_data.points[i];
                            line_data.push(parseFloat(point.value));
                        }
                    }
                    console.log(line_data)
                    $('#container').highcharts({
                        tooltip: {
                            enabled: false
                        },
                        chart: {
                            height: 200,
                            type: 'line'
                        },
                        title: {
                            text: ''
                        },
                        subtitle: {
                            text: ''
                        },
                        yAxis: {
                            title: {
                                text: ''
                            }
                        },
                        credits: {
                            enabled: false
                        },
                        colors: ['#F3F3F3'],
                        xAxis: {
                            // categories: ['', '', '', '', '', '', '', '', '', '', '', '']
                        },
                        series: [{
                            name: ' ',
                            data: line_data.length ? line_data : [0, 0]
                        }]
                    }, function (chart) { // on complete
                        var min = 1000,
                            max = 0,
                            pointsToShow = [0, 0],
                            points = chart.series[0].points;
                        Highcharts.each(points, function (p) {
                            if (p.y > max) {
                                pointsToShow[0] = p.index;
                                max = p.y;
                            }
                            if (p.y < min) {
                                pointsToShow[1] = p.index;
                                min = p.y;
                            }
                        });
                        render(chart, points[pointsToShow[0]], '￥');
                        render(chart, points[pointsToShow[1]], '￥');
                        //var point = chart.series[0].points[8];
                    });
                    function render(chart, point, text) {
                        // console.log(chart.renderer)
                        chart.renderer.label(text + ' ' + point.y, point.plotX + chart.plotLeft - 20, point.plotY + chart.plotTop - 45, 'callout', point.plotX + chart.plotLeft, point.plotY + chart.plotTop)
                            .css({
                                color: '#fff',
                                align: 'center',
                                borderWidth: "5px",
                                borderColor: "red",
                                borderStyle: "solid",

                            })
                            .attr({
                                fill: 'rgba(0, 0, 0, 0.75)',
                                padding: 8,
                                r: 5,
                                zIndex: 6,
                            })
                            .add();
                    }
                }
            })
        });
        $.ajax({
            type: 'GET',
            url: protocol + '://'+ host + '/order/orders/' + id,
            contentType: 'application/json',
            withCredentials: true,
            dataType: 'json',
            success: function (data) {
                $("title").html(data.product_info.name);
                $(".share_card_two").html(render_card(data.gift_info))
                $(".share_data").append(render_share_data(data.product_info))
                $(".chazhuang").append(render_chazhuang(data.product_info))
                $(".download").attr("href", data.app_download_link)
                storage.setItem("href", data.app_download_link);
                for (var i = 0; i < data.product_info.today_price_data.points.length; i++) {
                    var point = data.product_info.today_price_data.points[i];
                    line_data.push(parseFloat(point.value));
                }
                for (var i = 0; i < data.product_info.week_price_data.points.length; i++) {
                    var point = data.product_info.week_price_data.points[i];
                    weekdata.push(parseFloat(point.value));
                }
                for (var i = 0; i < data.product_info.month_price_data.points.length; i++) {
                    var point = data.product_info.month_price_data.points[i];
                    monthdata.push(parseFloat(point.value));
                }
                $('#container').highcharts({
                    tooltip: {
                        enabled: false
                    },
                    chart: {
                        height: 200,
                        type: 'line'
                    },
                    title: {
                        text: ''
                    },
                    subtitle: {
                        text: ''
                    },
                    yAxis: {
                        title: {
                            text: ''
                        }
                    },
                    credits: {
                        enabled: false
                    },
                    colors: ['#F3F3F3'],
                    xAxis: {
                        // categories: ['', '', '', '', '', '', '', '', '', '', '', '']
                    },
                    series: [{
                        name: ' ',
                        data: line_data.length ? line_data : [0, 0]
                    }]
                }, function (chart) { // on complete
                    var min = 1000,
                        max = 0,
                        pointsToShow = [0, 0],
                        points = chart.series[0].points;
                    Highcharts.each(points, function (p) {
                        if (p.y > max) {
                            pointsToShow[0] = p.index;
                            max = p.y;
                        }
                        if (p.y < min) {
                            pointsToShow[1] = p.index;
                            min = p.y;
                        }
                    });
                    render(chart, points[pointsToShow[0]], '￥');
                    render(chart, points[pointsToShow[1]], '￥');
                    //var point = chart.series[0].points[8];
                });
                function render(chart, point, text) {
                    console.log(chart.renderer)
                    chart.renderer.label(text + ' ' + point.y, point.plotX + chart.plotLeft - 20, point.plotY + chart.plotTop - 45, 'callout', point.plotX + chart.plotLeft, point.plotY + chart.plotTop)
                        .css({
                            color: '#fff',
                            align: 'center',
                            borderWidth: "5px",
                            borderColor: "red",
                            borderStyle: "solid",

                        })
                        .attr({
                            fill: 'rgba(0, 0, 0, 0.75)',
                            padding: 8,
                            r: 5,
                            zIndex: 6,
                        })
                        .add();
                }
            }
        })

    });
</script>
</html>